class Admin::ArtistDescriptionsController < Admin
  # GET /artist_descriptions
  # GET /artist_descriptions.xml
  def index
    @artist_descriptions = ArtistDescription.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @artist_descriptions }
    end
  end

  # GET /artist_descriptions/1
  # GET /artist_descriptions/1.xml
  def show
    @artist_description = ArtistDescription.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @artist_description }
    end
  end

  # GET /artist_descriptions/new
  # GET /artist_descriptions/new.xml
  def new
    @artist_description = ArtistDescription.new
    @artist = Artist.find(params[:artist_id])

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @artist_description }
    end
  end


  # DELETE /artist_descriptions/1
  # DELETE /artist_descriptions/1.xml
  def destroy
    @artist_description = ArtistDescription.find(params[:id])
    @artist_description.destroy
    @artist_description.artist.unpublish_if_necessary

    respond_to do |format|
      format.html { redirect_to(artist_descriptions_url) }
      format.xml  { head :ok }
    end
  end
  
    def update_description
    @artist_description = ArtistDescription.find(params[:id])
    old_bio = @artist_description.biography
    old_ps = @artist_description.personal_statement

    respond_to do |format|
      if @artist_description.update_attributes(params[:artist_description])
        format.js { render :update do |page|
          if old_bio != @artist_description.biography
            page.visual_effect :highlight, 'biography_' + @artist_description.id.to_s
          end
          if old_ps != @artist_description.personal_statement
            page.visual_effect :highlight, 'personal_statement_' + @artist_description.id.to_s            
          end
        end }
      else
        # TODO: error
        format.js { render :update do |page|
          
        end }
      end
    end
  end
end
